package com.jiayan.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiayan.mapper.EbProductMapper;
import com.jiayan.model.EbProduct;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class FurnitureService {
    @Resource
    private EbProductMapper ebProductMapper;


    public EbProduct detail(Integer pid){
        EbProduct ebProduct = ebProductMapper.selectById(pid);
        return ebProduct;
    }

    public Map<String, Object> list(int pnum) {
        Map<String, Object> result = new HashMap();
        //TODO 1.分页查询商品数据  默认第1页 每页10条数据
        Page<EbProduct> page = new Page<>(pnum, 10);
        Page<EbProduct> productPage = ebProductMapper.selectPage(page, Wrappers.<EbProduct>lambdaQuery().eq(EbProduct::getEpcId, "548"));
        //将数据封装的到Map集合
        result.put("productPage", productPage);
        return result;

    }
}
